package org.lw.bootstrap.dto;

import java.io.Serializable;

/**
 * 结果封装
 *
 */
public class Result implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7993029268677126061L;

	/**
	 * 错误码
	 */
	private String errorCode;

	/**
	 * 错误提示
	 */
	private String msg;
	
	/**
	 * 数据
	 */
	private Object data;
	
	/**
	 * 附件
	 */
	private Object attachment;
	
	/**
	 * 
	 */
	public Result() {
		this(null, null, null);
	}

	/**
	 * 
	 * @param errorCode
	 * @param msg
	 * @param data
	 */
	public Result(String errorCode, String msg, Object data) {
		this(errorCode, msg, data, null);
	}
	
	/**
	 * 
	 * @param errorCode
	 * @param msg
	 * @param data
	 * @param attachment
	 */
	public Result(String errorCode, String msg, Object data, Object attachment) {
		this.errorCode = errorCode;
		this.msg = msg;
		this.data = data;
		this.attachment = attachment;
	}
	
	public boolean isSucceed() {
		return ErrorCode.SUCCEED.name().equals(this.getErrorCode());
	}
	
	public boolean isSuccess() {
		return this.isSucceed();
	}

	public String getErrorCode() {
		return errorCode;
	}

	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public Object getAttachment() {
		return attachment;
	}

	public void setAttachment(Object attachment) {
		this.attachment = attachment;
	}
}
